<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/template/template_layout_lr.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
			.ui-button, .ui-button span, button.ui-button.ui-state-default span,
				.ui-button.ui-state-default span {
				font-weight: normal
			}
		</style>
		<script type="text/javascript">
			function start() {
				PF('statusDialog').show();
			}

			function stop() {
				PF('statusDialog').hide();
			}
		</script>
	</ui:define>
	<ui:define name="left-box-title">
		台风选择树
	</ui:define>
	<ui:define name="left-box-body">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div class="box-header with-border" id="searchContent">
			<h:form id="typhoonForm">
				<p:growl id="msg" showDetail="true" />
				<p:autoComplete placeholder="输入拼音首字母可查询" id="searchTyphoon"
					value="#{typhoonFaultInfoController.filterTyphoon}"
					completeMethod="#{typhoonFaultInfoController.completeTyphoon}" scrollHeight="400" style="float:left;">
					<p:ajax update="searchTyphoon typhoonTreeForm:tree" event="itemSelect"
						listener="#{typhoonFaultInfoController.autoCompleteTyphoon}" />
				</p:autoComplete>
				<p:commandButton icon="fa fa-refresh"
					style="margin-left:3px;height:30px;"
					update="searchTyphoon typhoonTreeForm:tree"
					actionListener="#{typhoonFaultInfoController.initTyphoonTree()}" 
					rendered="#{s:hasPermission(session,'jcsj_sjwh_gzhtfdgxxx_sxtfs')}" />
			</h:form>
		</div>
		<div class="box-body  with-border">
			<h:form id="typhoonTreeForm">
				<p:tree value="#{typhoonFaultInfoController.root}"
					style="width:400px;border:none" selectionMode="single" var="node"
					dynamic="true" id="tree" widgetVar="tree" animate="true">
					<p:ajax event="expand" update="tree"
						listener="#{typhoonFaultInfoController.onNodeExpand}" />
					<p:ajax event="select" process="@this" update="infoForm:infoTbs infoForm:tools createForm" 
						listener="#{typhoonFaultInfoController.onNodeSelect}" />
					<p:treeNode type="typhoon" icon="fa fa-home">
						<h:outputText value="#{node.tname}" />
					</p:treeNode>
					<p:treeNode type="typhoonObject" icon="fa fa-home">
						<h:outputText value="#{node.updateTime}" />
					</p:treeNode>
				</p:tree>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="right-box-title">
		相关故障信息
	</ui:define>
	<ui:define name="right-box-body">
		<div class="box-body full-content-scroll with-border">
			<h:form id="infoForm">
				<p:growl id="infoMsg" showDetail="true" />
				<p:toolbar id="tools">
					<f:facet name="left">
						<p:commandButton value="新建" icon="ui-icon-plus"
							update="createForm" disabled="#{typhoonFaultInfoController.currentTyphoon.id == null || 
							typhoonFaultInfoController.currentTyphoon.id == ''}" 
							actionListener="#{typhoonFaultInfoController.refreshFault}" oncomplete="PF('createDlg').show()" 
							rendered="#{s:hasPermission(session,'jcsj_sjwh_gzhtfdgxxx_xj')}" />
						<p:commandButton value="删除" actionListener="#{typhoonFaultInfoController.deleteInfo}" 
							disabled="#{typhoonFaultInfoController.selected == null}"
							update="infoTbs infoMsg tools" icon="ui-icon-trash" 
							rendered="#{s:hasPermission(session,'jcsj_sjwh_gzhtfdgxxx_sc')}">
							<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />	
						</p:commandButton>
					</f:facet>
				</p:toolbar>
				<p:dataTable id="infoTbs" var="info" rowKey="#{info.id}" rowIndexVar="ite" 
					value="#{typhoonFaultInfoController.infoList}" emptyMessage="没有记录"
					lazy="true" selection="#{typhoonFaultInfoController.selected}"
					style="margin-bottom:20px" rows="20" paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="20,50,100">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{typhoonFaultInfoController.infoList.size()} 条记录"
							style="margin-right:20px;"></p:outputLabel>
					</f:facet>
					<p:ajax event="rowSelectRadio" listener="#{typhoonFaultInfoController.onRowSelect}" update="infoForm:tools" />
					<p:column selectionMode="single" style="width:40px;text-align:center" />
					<p:column width="5%" headerText="序号 ">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="台风id">
						<h:outputText value="#{info.tid}" />
					</p:column>
					<p:column headerText="故障设备">
						<h:outputText value="#{info.name}" />
					</p:column>
					<p:column headerText="设备id">
						<h:outputText value="#{info.equipmentId}" />
					</p:column>
					<p:column headerText="设备经度">
						<h:outputText value="#{info.equipmentLon}" />
					</p:column>
					<p:column headerText="设备纬度">
						<h:outputText value="#{info.equipmentLat}" />
					</p:column>
					<p:column headerText="距台风点距离">
						<h:outputText value="#{info.distance}"/>
					</p:column>
					<p:column headerText="风圈">
						<h:outputText value="#{info.radius==-1?'其他':(info.radius==0?'未知':info.radius)}"/>
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="createForm">
				<p:dialog widgetVar="createDlg" header="新建关系" modal="true"
					id="createDlg" width="1100" height="500">
					<p:toolbar id="faultTool">
						<f:facet name="left">
							<p:growl id="faultMsg" showDetail="true" />
							<h:outputText value="故障设备：" />
							<p:inputText value="#{typhoonFaultInfoController.equipment}" />
							<p:outputLabel value="故障时间： " style="margin-left:5px" />
							<p:calendar pattern="yyyy-MM-dd" navigator="true" maxdate="Date()" readonlyInput="true" 
								value="#{typhoonFaultInfoController.startDate}" style="wigth:14px">
							</p:calendar>
							<p:outputLabel value="至 " style="margin-left:5px;margin-right:5px" />
							<p:calendar pattern="yyyy-MM-dd" navigator="true" maxdate="Date()" readonlyInput="true" 
								value="#{typhoonFaultInfoController.endDate}" style="wigth:14px">
							</p:calendar>
							<p:commandButton value="搜索" actionListener="#{typhoonFaultInfoController.searchFault}" 
								update="faultTbs faultTool faultMsg" icon="ui-icon-search" style="margin-left:5px" 
								rendered="#{s:hasPermission(session,'jcsj_sjwh_gzhtfdgxxx_ss')}" />
							<p:commandButton value="刷新" actionListener="#{typhoonFaultInfoController.refreshFault}" 
								update="faultTbs faultTool" icon="ui-icon-refresh" 
								rendered="#{s:hasPermission(session,'jcsj_sjwh_gzhtfdgxxx_sx')}" />
							<p:commandButton value="保存" actionListener="#{typhoonFaultInfoController.saveInfo}" 
								update="faultTbs faultTool faultMsg infoForm:infoTbs" icon="ui-icon-disk" 
								rendered="#{s:hasPermission(session,'jcsj_sjwh_gzhtfdgxxx_bc')}" />
						</f:facet>
					</p:toolbar>
					<p:dataTable id="faultTbs" var="fault" rowKey="#{fault.id}" rowIndexVar="ite" 
					value="#{typhoonFaultInfoController.faultList}" emptyMessage="没有记录"
					lazy="true" selection="#{typhoonFaultInfoController.selectedFault}" 
					style="margin-bottom:20px" rows="20" paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="20,50,100">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{typhoonFaultInfoController.faultList.size()} 条记录"
							style="margin-right:20px;"></p:outputLabel>
					</f:facet>
					<p:column selectionMode="multiple" style="width:40px;text-align:center" />
					<p:column width="6%" headerText="序号 ">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="故障设备">
						<h:outputText value="#{fault.equipment}" />
					</p:column>
					<p:column headerText="设备类型">
						<h:outputText value="#{fault.etype}" />
					</p:column>
					<p:column headerText="电压等级">
						<h:outputText value="#{fault.voltage}" />
					</p:column>
					<p:column headerText="故障时间">
						<h:outputText value="#{fault.faultTime}" />
					</p:column>
					<p:column headerText="故障原因">
						<h:outputText value="#{fault.faultReson}" />
					</p:column>
					<p:column headerText="故障类型">
						<h:outputText value="#{fault.faultType}" />
					</p:column>
					<p:column headerText="故障相别">
						<h:outputText value="#{fault.faultPhase}"/>
					</p:column>
				</p:dataTable>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
</ui:composition>